package tyk.Listener;

import javax.servlet.ServletContext;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
@WebListener
public class ListenerVisit implements HttpSessionListener {
    @Override
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
        ServletContext application=httpSessionEvent.getSession().getServletContext();
        Integer VisitCount= (Integer) application.getAttribute("VisitCount");
        if(VisitCount==null) VisitCount=(Integer) 0;
        VisitCount++;
        application.setAttribute("VisitCount",VisitCount);
        //System.out.println(VisitCount);

    }

    @Override
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {

    }
}
